package light.head.dao.el;

import java.util.List;

import org.springframework.stereotype.Service;

import light.head.framework.base.BaseDAO;
import light.head.model.el.Learn;
@Service
public class LearnDAO extends BaseDAO<Learn, Integer>{
	/**
	 * 根据班级、课程、资料、资料附件、学员编号获取学习情况
	 */
	
	public Learn getOne(Integer clc, Integer cc, Integer tmc, Integer tmac, Integer cu){
		if(clc == null || cc == null || tmc == null || tmac == null || cu == null) return null;
		String sql = "FROM Learn l WHERE l.deleted = 0 AND l.clc = ? AND l.cc = ? AND l.tmc = ? AND l.tmac = ? AND l.cu = ?";
		List<Learn> list = findI(sql, clc, cc, tmc, tmac, cu);
		return list != null && list.size() > 0 ? list.get(0) : null;
	}
	
	
	public List<Learn> findByClcAndUcAndCc(Integer clc,Integer uc,Integer cc){
		String hql = "FROM Learn l WHERE l.deleted = 0 AND l.clc = ? AND l.cu = ? AND l.cc = ?";
		return findI(hql, clc,uc,cc);
	}
	
	public Long findByClcAndCc(Integer tmac,Integer clc,Integer cc,Integer cu){
		String hql = "SELECT l.time FROM Learn l WHERE l.deleted = 0 AND l.tmac = ? AND l.clc = ? AND l.cc = ? AND l.cu = ?";
		return (Long)get(hql,tmac,clc,cc,cu);
	}
	public List<Learn> findByClcAndCc(Integer clc,Integer cc){
		String hql = "FROM Learn l WHERE l.deleted = 0 AND l.clc = ? AND l.cc = ?";
		return findI(hql, clc,cc);
	}
}
